//
//  ArgumentError
//
//  Created by Caue W. on 2011-03-07.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
package time;
import time.compiler.types.Data;
private typedef Pos = haxe.macro.Expr.Position;

enum Message
{
	S(msg:String, ?pos:Null<Pos>); //un-formatted output
	F(msg:String, formats:Array<Dynamic>, ?pos:Null<Pos>); //formatted output
}

enum ArgumentError 
{
	ObjectWithUnknownKey(obj:Dynamic);
}

enum PlatformError
{
	UnsupportedAsyncOperation;
	UnsupportedSyncOperation;
}

enum ConstraintError
{
	NotNullFieldNotSet(field:String);
}

enum LibraryError
{
	NotImplemented;
	Assert;
} 

enum MacroError
{
	RequiresMacroContext;
}

enum ParserError
{
	PError(msg:String, pos:Pos);
	SolverError(msg:String, pos:Pos);
}

//TODO clean UP those messy enums. Such enum-based errors really won't work with this lib
enum RttiError
{
	InvalidType(t:DBType, ?pos:Null<Pos>);
	TypeNotFound(path:String);
	MetadataError(msg:String, pos:Pos);
	InvalidExpr(e:haxe.macro.Expr);
	FieldNotFound(type:DBType, field:String);
	UnsupportedType(t:haxe.macro.Type);
	TypeCannotBeReferenced(t:DBType, canBeWrapped:Bool, ?pos:Null<Pos>);
	RttiError(msg:String, ?pos:Null<Pos>);
}

//TODO clean up errors into logical error structure
enum TypeError
{
	
}

enum HierarchyMismatchError
{
	//thrown when a unique child is required (e.g. when a reference is used), and the instance has multiple parents
	UniqueChildMultipleParentsError(dbtype:DBType, parents:Array<{type:DBType, valueType:Bool, parentField:String}>, ?pos:Null<Pos>);
	//thrown when type is required to be value type, but it can't (in case of e.g. ToMany references - they can't be embedded)
	CannotBeValueType(type:DBType, ?pos:Null<Pos>);
	IncompatibleKind(k1:MemberKind, k2:MemberKind, pos:Null<Pos>);
}